﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RegExTemplate.aspx.cs" Inherits="TestFrame.RegExTemplate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script id="temp" type="text/html">
        {%if (name === "ac") %}
            <li><a>{%= label %}<br />{%= desc %}</a></li>
        {%else%}
            <li><a>{%= desc %}<br />{%= label %}</a></li>
        {%if%}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
    </div>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            var temp = $("head script#temp");

            temp.html().replace(/({%.+?%})/g, "\t$1\t");
            /// this regex match will match a any pattern containing a start {% and a end %} and the contents in between.
            temp.html().replace(/{%(\W|\w+)[\s]?[\(]?(.+?)?[\)]?[\s]?%}/gi, function (match, type) {
                var args = arguments, index = args[args.length - 2], src = args[args.length - 1]

                alert("block '" + type + "' found.");
            });

            function test($data) {
                var $=jQuery,_=[],index=$i,print=function(){_.push.apply(_, arguments);};with($data){_.push("<li><a>");_.push($.encode(typeof label === 'function' ? label.call(this) : label));_.push("<br /><span style=\"font-size: 7pt\">");_.push($.encode(typeof desc === 'function' ? desc.call(this) : desc));_.push("</span></a></li>");}return _.join('');
            }

            alert(test({ label: "jQuery.Net", desc: "render template test"}));
        });
    </script>
</body>
</html>
